package com.api.shopapi.mapper;

import com.api.shopapi.entity.CashierCartGoodsPrice;
import com.api.shopapi.entity.dto.CashierCartGoodsPriceDTO;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface CashierCartGoodsPriceMapper {


    @Insert("insert into cashier_cart_goods_price " +
            "(" +
            "CashierCartGoodsPriceCode, " +
            "CashierCartGoodsCode, " +
            "GoodsSizeCode, " +
            "GoodsColorCode, " +
            "Price" +
            ") " +
            "VALUES " +
            "(#{cashierCartGoodsPrice.CashierCartGoodsPriceCode} ," +
            "#{cashierCartGoodsPrice.CashierCartGoodsCode} ," +
            "#{cashierCartGoodsPrice.GoodsSizeCode} ," +
            "#{cashierCartGoodsPrice.GoodsColorCode} ," +
            "#{cashierCartGoodsPrice.Price} " +
            ") ")
    int insert(@Param("cashierCartGoodsPrice") CashierCartGoodsPrice cashierCartGoodsPrice);

    @Delete("delete from cashier_cart_goods_price where cashierCartGoodsPriceCode=#{cashierCartGoodsPriceCode}")
    int delete(@Param("cashierCartGoodsPriceCode") String cashierCartGoodsPriceCode);



    @Update("update cashier_cart_goods_price " +
            "set " +
            "CashierCartGoodsCode=#{cashierCartGoodsPrice.CashierCartGoodsCode}," +
            "GoodsSizeCode=#{cashierCartGoodsPrice.GoodsSizeCode}," +
            "GoodsColorCode=#{cashierCartGoodsPrice.GoodsColorCode} , " +
            "Price=#{cashierCartGoodsPrice.Price} " +
            "where " +
            "CashierCartGoodsPriceCode=#{cashierCartGoodsPrice.CashierCartGoodsPriceCode}    ")
    int update(@Param("cashierCartGoodsPrice") CashierCartGoodsPrice cashierCartGoodsPrice);

    @Select("select  * from cashier_cart_goods_price")
    List<CashierCartGoodsPrice> getList();

    @Select("select  * from cashier_cart_goods_price where CashierCartGoodsPriceCode=#{cashierCartGoodsPriceCode} limit 1")
    CashierCartGoodsPrice getByCashierCartGoodsPriceCode(@Param("cashierCartGoodsPriceCode") String cashierCartGoodsPriceCode);

    @Select("select  * from cashier_cart_goods_price where cashierCartGoodsCode=#{cashierCartGoodsCode} limit 1")
    CashierCartGoodsPriceDTO getByCashierCartGoodsCode(@Param("cashierCartGoodsCode") String cashierCartGoodsCode);


}
